import java.util.StringTokenizer;

class P10905_39643 {

    public static void main(String[] args) {
    	
    	String line = readLn();
    	
    	while (!"0".equals(line)) {
    		int length = Integer.parseInt(line);
    		process(length);
    		line = readLn();
    	}
    	
    }

	private static void process(int length) {
		String[] numbers = new String[length];
		StringTokenizer st = new StringTokenizer(readLn());
		for (int k = 0; k < length; k++) {
			numbers[k] = st.nextToken();
		}
		
		for (int k = 0; k < length; k++) {
			for (int j = 0; j < length; j++) {
				if (compare(numbers, k, j)) {
					swap(numbers, k, j);
				}
			}
		}
		
		StringBuffer sb = new StringBuffer();
		for (int k = 0; k < length; k++) {
			sb.append(numbers[k]);
		}
		
		System.out.println(sb.toString());
	}


	private static void swap(String[] numbers, int k, int j) {
String aux = numbers[k];
numbers[k] = numbers[j];
numbers[j] = aux;
		
	}


	private static boolean compare(String[] numbers, int k, int j) {
		String a = numbers[k] + numbers[j];
		String b = numbers[j] + numbers[k];
		if (a.compareTo(b) > 0) {
			return true;
		}
		return false;
	}


	static String readLn() {
        String newLine = System.getProperty("line.separator");
        StringBuffer buffer = new StringBuffer();
        int car = -1;
        try {
            car = System.in.read();
            while ((car > 0) && (car != newLine.charAt(0))) {
                buffer.append((char)car);
                car = System.in.read();
            }
            if (car == newLine.charAt(0))
            System.in.skip(newLine.length() - 1);
        } catch (java.io.IOException e) { return (null);}
        if ((car < 0) && (buffer.length() == 0)) return (null);
        return (buffer.toString()).trim();
    }

}